package daniel.taotao.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import daniel.taotao.common.pojo.EasyUITreeNode;
import daniel.taotao.common.utils.TaotaoResult;
import daniel.taotao.content.service.ContentCategoryService;

@Controller
public class ContentCataController {
	@Autowired
	private ContentCategoryService contentCategoryService;
	@RequestMapping("/content/category/list")
	@ResponseBody
	public List<EasyUITreeNode> getContentCatagoryList(@RequestParam(name="id",defaultValue="0" )Long parentId){
		List<EasyUITreeNode> contCataList = contentCategoryService.getContCataList(parentId);
		return contCataList;
	}
	@RequestMapping("/content/category/create")
	@ResponseBody
	public TaotaoResult addContentCatagory(Long parentId,String name){
		TaotaoResult taotaoResult = contentCategoryService.addContentCategory(parentId, name);
		
		return taotaoResult;
	}
	
	@RequestMapping("/content/category/update")
	public void updateContentCatagory(Long id,String name){
		contentCategoryService.updateContentCategory(id, name);
	}
	
	@RequestMapping("/content/category/delete/")
	public void updateContentCatagory(Long id){
		contentCategoryService.deleteContentCategory(id);
	}
}
